﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Entities;

namespace Mapping
{
    public class GroupMap : ClassMap<Group>
    {
        public GroupMap()
        {
            Id(x => x.Id).GeneratedBy.Identity();
            Map(x => x.GroupTitle).Not.Nullable();
            Map(x => x.Course).Not.Nullable();
            Map(x => x.StudentCount).Not.Nullable();
            References(x => x.Direction)
                .Column("DirectionId")
                .ForeignKey()                
                .Cascade.SaveUpdate();
            HasManyToMany(x => x.LoadAtoms)
                .ParentKeyColumn("GroupId")
                .ChildKeyColumn("LoadAtomId")
                .Cascade.All()
                .Inverse()
                .Table("GroupLoadAtom");
        }
    }
}
